#include "Display.h"
#include "FreeRTOS.h"
#include "lvgl_driver/lv_port_disp.h"
#include "lvgl.h"

TFT_eSPI tft = TFT_eSPI();

TaskHandle_t handleTaskLvgl;
void TaskLvglUpdate(void* parameter)
{
    ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

    for (;;)
    {
        lv_task_handler();
        delay(5);
    }
}

void Display_init(void)
{
    tft.init();
    tft.setRotation(0);
    tft.fillScreen(TFT_WHITE);

    /* lvgl初始化 */
    lv_init();
    lv_port_disp_init();

    // Update display in parallel thread.
    xTaskCreate(
        TaskLvglUpdate,
        "LvglThread",
        20000,
        nullptr,
        configMAX_PRIORITIES - 1,
        &handleTaskLvgl);
}
